﻿/// <Summary> 
/// $Author: Nikhil Chinchwade 
/// This file contains classes representing performance monitoring counters

/// </summary>
/// 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;


namespace MindTree.PerfWorkbench.Azure.Monitor.Core
{
    /// <summary>
    /// Class representing a performance counter set
    /// </summary>
    public class CounterSet
    {
        public string Name
        {
            get;
            set;
        }

        
        private IList<PerfCounter> counters = new List<PerfCounter>();

        /// <summary>
        /// List of Performance Counters
        /// </summary>
        public IList<PerfCounter> Counters
        {
            get
            {
                return counters;
            }
            set
            {
                counters = value;
            }
        }
        
        public int Index
        {
            get;
            set;
        }              

        public void IsChecked(object sender, RoutedEventArgs args)
        {
            //return true;
        }


        /// <summary>
        /// Parameterised Constructor
        /// </summary>
        /// <param name="paramCntrs">List of perforamnce Counters</param>
        public CounterSet(IList<PerfCounter> paramCntrs)
        {
            Counters = paramCntrs;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void SelectionChanged(object sender, RoutedEventArgs args)
        {
            CheckBox chkbox1 = sender as CheckBox; 
            
            ContentPresenter contentRow = chkbox1.TemplatedParent as ContentPresenter;
            GridViewRowPresenter grdrowpresenter = contentRow.Parent as GridViewRowPresenter;
            if (chkbox1.IsChecked.GetValueOrDefault())
            {
                if (!((AzureRoleInstance)grdrowpresenter.Content).CounterSetIndex.Contains(Index))
                {
                    ((AzureRoleInstance)grdrowpresenter.Content).CounterSetIndex.Add(Index);
                }
            }
            else
            {
                if (((AzureRoleInstance)grdrowpresenter.Content).CounterSetIndex.Contains(Index))
                {
                    ((AzureRoleInstance)grdrowpresenter.Content).CounterSetIndex.Remove(Index);
                }
            }      
            
            /*  14th 
             if (chkbox1.IsChecked.GetValueOrDefault())
            {
                if (!((List<AzureRoleInstance>)grdrowpresenter.Content)[0].CounterSetIndex.Contains(Index))
                {
                    ((List<AzureRoleInstance>)grdrowpresenter.Content)[0].CounterSetIndex.Add( Index );
                }
            }
            else
            {
                if (((List<AzureRoleInstance>)grdrowpresenter.Content)[0].CounterSetIndex.Contains(Index))
                {
                    ((List<AzureRoleInstance>)grdrowpresenter.Content)[0].CounterSetIndex.Remove(Index);
                }
            }            */
        }

        //public void EditCounters(object sender, RoutedEventArgs args)
        //{

        //}
    }
}
